#include <iostream>
#include <vector>
#include "types.h"
extern std::vector <user> Subjects;
extern std::vector <file> Objects;
extern std::vector <SOA> ACM;
void print_subjects()
{
    std::vector <user>::iterator it;
    std::cout << std::endl;
    std::cout << "name" << "\t" << "password" << std::endl;
    for(it = Subjects.begin(); it != Subjects.end(); it ++)
    {
        std::cout << it->name << "\t" << it->password << std::endl;
    }
    std::cout << std::endl;
}

void print_objects()
{
    std::vector <file>::iterator it;
    std::cout << std::endl;
    std::cout << "filename" << "\t" << "creator" << "\t" << "content" << std::endl;
    for(it = Objects.begin(); it != Objects.end(); it ++)
    {
        std::cout << it->filename << "\t" << it->creator << "\t" << it->content << std::endl;
    }
    std::cout << std::endl;
}

void print_acm()
{
    #define ACCESS_TO_NAME(a) names[a]
    std::string names [] = {"NULL", "READ", "WRITE", "NULL", "OWN"}; 
    std::vector <SOA>::iterator it;
    std::cout << std::endl;
    std::cout << "username" << "\t" << "filename" << "\t" << "access" << "\t" << "from_to" << std::endl;
    for(it = ACM.begin(); it != ACM.end(); it ++)
    {
        std::cout << it->user << "\t" << it->filename << "\t" << ACCESS_TO_NAME(it->access) << "\t" << it->from_to << std::endl;
    }
    std::cout << std::endl;
}

void print_all()
{
    print_subjects();
    print_objects();
    print_acm();
}